#ifndef __BRANCH1_BRANCH1_COMMON_TOOLS_H__
#define __BRANCH1_BRANCH1_COMMON_TOOLS_H__
#include "Branch1BaseConfig.h"
#include <ogre\Ogre.h>
using namespace  Ogre;
namespace DAISY{
	class CommonTool
	{

	public:

		static void DestroyAllAttachedMovableObjects( SceneNode* i_pSceneNode )
		{
			if ( !i_pSceneNode )
			{

				return;
			}

			// Destroy all the attached objects
			SceneNode::ObjectIterator itObject = i_pSceneNode->getAttachedObjectIterator();

			while ( itObject.hasMoreElements() )
			{
				Ogre::MovableObject* pObject = static_cast<Ogre::MovableObject*>(itObject.getNext());
				i_pSceneNode->getCreator()->destroyMovableObject( pObject );
			}

			// Recurse to child SceneNodes
			SceneNode::ChildNodeIterator itChild = i_pSceneNode->getChildIterator();

			while ( itChild.hasMoreElements() )
			{
				SceneNode* pChildNode = static_cast<SceneNode*>(itChild.getNext());
				DestroyAllAttachedMovableObjects( pChildNode );
			}
		}
	};
}
#endif